

import java.util.Hashtable;
import java.util.Vector;
public class Parametros {

    private Vector orderedKeys;
    private Hashtable parameters;

    public Parametros() {
        orderedKeys = new Vector();
        parameters = new Hashtable();
    }

    public void addParam(String key, String value) {
        if (parameters.get(key) == null) {
            orderedKeys.addElement(key);
            parameters.put(key, value);
        } else {
            parameters.remove(key);
            parameters.put(key, value);
        }
    }

    public void deleteParam(String key) {
        parameters.remove(key);
        orderedKeys.removeElement(key);
    }

    public String getKey(String key) {
        return (String) parameters.get(key);
    }

    public boolean contains(String key) {
        return this.parameters.containsKey("action");
    }

    public String toString() {
        if (orderedKeys.size() > 0) {
            String direccion = "";
            for (int i = 0; i < orderedKeys.size(); i++) {
                String key = (String) orderedKeys.elementAt(i);
                direccion += key + "=" + parameters.get(key).toString()+ "&";
            }
            return direccion.substring(0, direccion.length() - 1);
        }
        return "";
    }
}
